<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        $(function () {
            login();
            car();
        })
        //获取是否有登录
        function login() {
            $.ajax({
                url:"easybuy/logined",
                success:function (data) {
                    var user=data.user;
                    $("#login").empty();
                    if (user!=null && user!=''){
                        //加时操作
                        $.ajax({
                            url:"easybuy/time"
                        });

                        //加载购物车
                        car();
                        if (user.type==1){
                            $("#login").append("你好，"+user.username+"&nbsp; <a id='logout' href='javascript:;' style=\"color:#ff4e00;\">注销</a>&nbsp;|&nbsp;<a href=\"admin.html\">管理页面</a>&nbsp;");
                        }else {
                            $("#login").append("你好，"+user.username+"&nbsp; <a id='logout' href='javascript:;' style=\"color:#ff4e00;\">注销</a>&nbsp;|&nbsp;<a href=\"Member.html\">用户管理</a>&nbsp;");

                        }

                        /*toCarDetails();*/

                    }else if (data==null||data==""){
                        $(".un_login").append("还未登录！<a href=\"Login.html\" style=\"color:#ff4e00;\">马上登录</a> 查看购物车！");
                        $("#login").append("你好，请<a href=\"Login.html\">登录</a>&nbsp; <a href=\"Regist.html\" style=\"color:#ff4e00;\">免费注册</a>&nbsp;");
                        $(".m_left").empty();
                        $(".m_right").attr("style","float:none;background-color:#ffffff");
                    }

                    //用户注销
                    $("#logout").unbind("click").click(function () {
                        $.ajax({
                            url: "easybuy/logout",
                            data:{
                                loginname:data.loginname
                            },
                            success:function (data) {
                                if (data=="success"){
                                    alert("注销成功！");
                                    location.href="index.html";
                                }else {
                                    alert("注销失败，请与管理员联系！");
                                }
                            }
                        })
                    });
                }
            });
        }
        //购物车加载
        function car(){
            $.ajax({
                url:"easybuy/carprolist",
                success:function (param){
                    var products = param.products;
                    var prices = param.prices;
                    if (products!=""&&products!=null){
                        var countsum = 0;
                        $(".cars").empty();
                        $(".prices").empty();
                        $.each(products,function (index,product) {
                            $(".cars").append("" +
                                "                <li>\n" +
                                "                    <div class=\"img\"><a href=\"#\"><img src=\"http://47.104.137.246:9999/files/"+product.filename+"\" width=\"58\" height=\"58\" /></a></div>\n" +
                                "                    <div class=\"name\"><a href=\"#\">"+product.name+"</a></div>\n" +
                                "                    <div class=\"price\"><font color=\"#ff4e00\">￥"+product.price+"</font> X"+product.carcount+"</div>\n" +
                                "                </li>");
                            countsum = countsum + product.carcount;
                        });
                        $(".prices").append("" +
                            "<div class=\"price_sum\">共计&nbsp; <font color=\"#ff4e00\">￥</font><span>"+prices+"</span></div>\n" +
                            "            <div class=\"price_a\"><a href=\"BuyCar.html\">去购物车结算</a></div>");
                        $(".car_t").children("span").html(products.length);
                    }

                }
            })
        }

        //购物车详情跳转
        /*function toCarDetails() {
            $(".i_car").click(function (){
                location.href = "BuyCar.html";
            });
        }*/

    </script>
</head>
<body>
<div class="soubg">
    <div class="sou">
        <!--Begin 所在收货地区 Begin-->
        <!-- <span class="s_city_b">
                 <span class="fl">送货至：</span>
                 <span class="s_city">
                     <span>四川</span>
                     <div class="s_city_bg">
                         <div class="s_city_t"></div>
                         <div class="s_city_c">
                             <h2>请选择所在的收货地区</h2>
                             <table border="0" class="c_tab" style="width:235px; margin-top:10px;" cellspacing="0" cellpadding="0">
                               <tr>
                                 <th>A</th>
                                 <td class="c_h"><span>安徽</span><span>澳门</span></td>
                               </tr>
                               <tr>
                                 <th>B</th>
                                 <td class="c_h"><span>北京</span></td>
                               </tr>
                               <tr>
                                 <th>C</th>
                                 <td class="c_h"><span>重庆</span></td>
                               </tr>
                               <tr>
                                 <th>F</th>
                                 <td class="c_h"><span>福建</span></td>
                               </tr>
                               <tr>
                                 <th>G</th>
                                 <td class="c_h"><span>广东</span><span>广西</span><span>贵州</span><span>甘肃</span></td>
                               </tr>
                               <tr>
                                 <th>H</th>
                                 <td class="c_h"><span>河北</span><span>河南</span><span>黑龙江</span><span>海南</span><span>湖北</span><span>湖南</span></td>
                               </tr>
                               <tr>
                                 <th>J</th>
                                 <td class="c_h"><span>江苏</span><span>吉林</span><span>江西</span></td>
                               </tr>
                               <tr>
                                 <th>L</th>
                                 <td class="c_h"><span>辽宁</span></td>
                               </tr>
                               <tr>
                                 <th>N</th>
                                 <td class="c_h"><span>内蒙古</span><span>宁夏</span></td>
                               </tr>
                               <tr>
                                 <th>Q</th>
                                 <td class="c_h"><span>青海</span></td>
                               </tr>
                               <tr>
                                 <th>S</th>
                                 <td class="c_h"><span>上海</span><span>山东</span><span>山西</span><span class="c_check">四川</span><span>陕西</span></td>
                               </tr>
                               <tr>
                                 <th>T</th>
                                 <td class="c_h"><span>台湾</span><span>天津</span></td>
                               </tr>
                               <tr>
                                 <th>X</th>
                                 <td class="c_h"><span>西藏</span><span>香港</span><span>新疆</span></td>
                               </tr>
                               <tr>
                                 <th>Y</th>
                                 <td class="c_h"><span>云南</span></td>
                               </tr>
                               <tr>
                                 <th>Z</th>
                                 <td class="c_h"><span>浙江</span></td>
                               </tr>
                             </table>
                         </div>
                     </div>
                 </span>
             </span>-->
        <!--End 所在收货地区 End-->
        <span class="fr">
        	<span class="fl" id="login"></span>
            <!--<span class="ss">
                <div class="ss_list">
                    <a href="#">收藏夹</a>
                    <div class="ss_list_bg">
                        <div class="s_city_t"></div>
                        <div class="ss_list_c">
                            <ul>
                                <li><a href="#">我的收藏夹</a></li>
                                <li><a href="#">我的收藏夹</a></li>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="ss_list">
                    <a href="#">客户服务</a>
                    <div class="ss_list_bg">
                        <div class="s_city_t"></div>
                        <div class="ss_list_c">
                            <ul>
                                <li><a href="#">客户服务</a></li>
                                <li><a href="#">客户服务</a></li>
                                <li><a href="#">客户服务</a></li>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="ss_list">
                    <a href="#">网站导航</a>
                    <div class="ss_list_bg">
                        <div class="s_city_t"></div>
                        <div class="ss_list_c">
                            <ul>
                                <li><a href="#">网站导航</a></li>
                                <li><a href="#">网站导航</a></li>
                            </ul>
                        </div>
                    </div>
                </div>
            </span>-->
            <span class="fl">|&nbsp;关注我们：</span>
            <span class="s_sh"><a href="#" class="sh1">新浪</a><a href="#" class="sh2">微信</a></span>
            <span class="fr">|&nbsp;<a href="#">手机版&nbsp;<img src="images/s_tel.png" align="absmiddle" /></a></span>
        </span>
    </div>
</div>
<div class="top">
    <div class="logo"><a href="Index.html"><img src="images/logo.png" /></a></div>
    <div class="i_car">
        <div class="car_t">购物车 [ <span>空</span> ]</div>
        <div class="car_bg">
            <!--Begin 购物车未登录 Begin-->
            <div class="un_login">
                <!--                还未登录！<a href="Login.html" style="color:#ff4e00;">马上登录</a> 查看购物车！-->
            </div>
            <!--End 购物车未登录 End-->
            <!--Begin 购物车已登录 Begin-->
            <ul class="cars">
                <!--                <li>-->
                <!--                    <div class="img"><a href="#"><img src="images/car1.jpg" width="58" height="58" /></a></div>-->
                <!--                    <div class="name"><a href="#">法颂浪漫梦境50ML 香水女士持久清新淡香 送2ML小样3只</a></div>-->
                <!--                    <div class="price"><font color="#ff4e00">￥399</font> X1</div>-->
                <!--                </li>-->
                <!--                <li>-->
                <!--                    <div class="img"><a href="#"><img src="images/car2.jpg" width="58" height="58" /></a></div>-->
                <!--                    <div class="name"><a href="#">香奈儿（Chanel）邂逅活力淡香水50ml</a></div>-->
                <!--                    <div class="price"><font color="#ff4e00">￥399</font> X1</div>-->
                <!--                </li>-->
                <!--                <li>-->
                <!--                    <div class="img"><a href="#"><img src="images/car2.jpg" width="58" height="58" /></a></div>-->
                <!--                    <div class="name"><a href="#">香奈儿（Chanel）邂逅活力淡香水50ml</a></div>-->
                <!--                    <div class="price"><font color="#ff4e00">￥399</font> X1</div>-->
                <!--                </li>-->
            </ul>
            <div class="prices">
                <!--            <div class="price_sum">共计&nbsp; <font color="#ff4e00">￥</font><span>1058</span></div>-->
                <!--            <div class="price_a"><a href="#">去购物车结算</a></div>-->
            </div>

            <!--End 购物车已登录 End-->
        </div>
    </div>
</div>

</body>
</html>